{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {},
   "outputs": [],
   "source": [
    "import gym\n",
    "import vh_graph\n",
    "import time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Imports done\n",
      "Env created\n"
     ]
    }
   ],
   "source": [
    "print('Imports done')\n",
    "env = gym.make('vh_graph-v0')\n",
    "print('Env created')\n",
    "state_path = 'example_graph/example_graph.json'\n",
    "task_goals = {0: '(inside cup[2009] bathroom[1])', 1: '(ontop video_game_controller[2006] kitchen_counter_[230])'}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Restart...\n",
      "Loading graph...\n",
      "Loaded\n"
     ]
    }
   ],
   "source": [
    "print('Restart...')\n",
    "s = env.reset(state_path , task_goals)\n",
    "env.to_pomdp()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "metadata": {},
   "outputs": [],
   "source": [
    "objects, predicates = env.get_objects_and_predicates(0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['[walk] <bathroom> (1)', '[walk] <bedroom> (67)', '[walk] <window> (86)', '[walk] <ceilinglamp> (96)', '[walk] <tablelamp> (97)', '[walk] <tablelamp> (98)', '[walk] <trashcan> (99)', '[walk] <nightstand> (100)', '[walk] <bookshelf> (101)', '[walk] <nightstand> (102)', '[walk] <chair> (103)', '[walk] <desk> (104)', '[walk] <bed> (105)', '[walk] <chair> (106)', '[walk] <table> (107)', '[walk] <dresser> (108)', '[walk] <dresser> (123)', '[walk] <doorjamb> (165)', '[walk] <mouse> (166)', '[walk] <mousepad> (167)', '[walk] <keyboard> (168)', '[walk] <light> (169)', '[walk] <computer> (170)', '[walk] <cpuscreen> (171)', '[walk] <mat> (173)', '[walk] <drawing> (174)', '[walk] <drawing> (175)', '[walk] <drawing> (176)', '[walk] <orchid> (178)', '[walk] <curtain> (181)', '[walk] <pillow> (182)', '[walk] <pillow> (183)', '[walk] <dining_room> (201)', '[walk] <home_office> (319)', '[walk] <picture> (2004)', '[walk] <oil> (2008)', '[walk] <napkin> (2010)', '[walk] <pencil> (2011)']\n",
      "***********************************************\n",
      "['[walk] <bathroom> (1)', '[walk] <bedroom> (67)', '[walk] <window> (86)', '[walk] <ceilinglamp> (96)', '[walk] <tablelamp> (97)', '[walk] <tablelamp> (98)', '[walk] <trashcan> (99)', '[walk] <nightstand> (100)', '[walk] <bookshelf> (101)', '[walk] <nightstand> (102)', '[walk] <chair> (103)', '[walk] <desk> (104)', '[walk] <bed> (105)', '[walk] <chair> (106)', '[walk] <table> (107)', '[walk] <dresser> (108)', '[walk] <dresser> (123)', '[walk] <doorjamb> (165)', '[walk] <mouse> (166)', '[walk] <mousepad> (167)', '[walk] <keyboard> (168)', '[walk] <light> (169)', '[walk] <computer> (170)', '[walk] <cpuscreen> (171)', '[walk] <mat> (173)', '[walk] <drawing> (174)', '[walk] <drawing> (175)', '[walk] <drawing> (176)', '[walk] <orchid> (178)', '[walk] <curtain> (181)', '[walk] <pillow> (182)', '[walk] <pillow> (183)', '[walk] <dining_room> (201)', '[walk] <home_office> (319)', '[walk] <picture> (2004)', '[walk] <oil> (2008)', '[walk] <napkin> (2010)', '[walk] <pencil> (2011)']\n"
     ]
    }
   ],
   "source": [
    "actions_0 = env.get_action_space(0)\n",
    "actions_1 = env.get_action_space(1)\n",
    "print(actions_0)\n",
    "print('***********************************************')\n",
    "print(actions_1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['[walk] <bathroom> (1)', '[walk] <bedroom> (67)', '[walk] <dining_room> (201)', '[walk] <door> (222)', '[walk] <ceilinglamp> (223)', '[walk] <ceilinglamp> (224)', '[walk] <tvstand> (225)', '[walk] <table> (226)', '[walk] <bench> (227)', '[walk] <bench> (228)', '[walk] <cupboard> (229)', '[walk] <kitchen_counter> (230)', '[walk] <faucet> (232)', '[walk] <bookshelf> (233)', '[walk] <wallshelf> (234)', '[walk] <wallshelf> (235)', '[walk] <mat> (236)', '[walk] <mat> (237)', '[walk] <drawing> (238)', '[walk] <drawing> (239)', '[walk] <drawing> (240)', '[walk] <drawing> (241)', '[walk] <drawing> (242)', '[walk] <drawing> (243)', '[walk] <orchid> (244)', '[walk] <light> (245)', '[walk] <powersocket> (246)', '[walk] <phone> (247)', '[walk] <television> (248)', '[walk] <wall_clock> (249)', '[walk] <photoframe> (285)', '[walk] <stovefan> (288)', '[walk] <freezer> (289)', '[walk] <coffe_maker> (290)', '[walk] <toaster> (292)', '[walk] <oven> (295)', '[walk] <microwave> (297)', '[walk] <home_office> (319)', '[walk] <knife> (2003)', '[walk] <cup> (2009)', '[turnto] <dining_room> (201)', '[turnto] <home_office> (319)']\n",
      "***********************************************\n",
      "['[walk] <bathroom> (1)', '[walk] <bedroom> (67)', '[walk] <dining_room> (201)', '[walk] <home_office> (319)', '[walk] <doorjamb> (346)', '[walk] <doorjamb> (347)', '[walk] <window> (348)', '[walk] <ceilinglamp> (349)', '[walk] <walllamp> (350)', '[walk] <walllamp> (351)', '[walk] <couch> (352)', '[walk] <tvstand> (353)', '[walk] <bookshelf> (354)', '[walk] <chair> (356)', '[walk] <desk> (357)', '[walk] <dresser> (358)', '[walk] <filing_cabinet> (399)', '[walk] <drawing> (400)', '[walk] <mat> (401)', '[walk] <drawing> (402)', '[walk] <drawing> (403)', '[walk] <drawing> (404)', '[walk] <pillow> (405)', '[walk] <curtain> (409)', '[walk] <television> (410)', '[walk] <light> (411)', '[walk] <powersocket> (412)', '[walk] <mouse> (413)', '[walk] <mousepad> (414)', '[walk] <keyboard> (415)', '[walk] <cpuscreen> (416)', '[walk] <computer> (417)', '[walk] <photoframe> (430)', '[walk] <form> (2002)', '[walk] <check> (2005)', '[walk] <video_game_controller> (2006)', '[walk] <dvd_player> (2012)', '[turnto] <dining_room> (201)', '[turnto] <home_office> (319)']\n",
      "***********************************************\n",
      "[0.0, 0.0]\n"
     ]
    }
   ],
   "source": [
    "rewards, states, infos = env.step({0: '[walk] <dining_room> (201)', 1: '[walk] <home_office> (319)'})\n",
    "actions_0 = env.get_action_space(0)\n",
    "actions_1 = env.get_action_space(1)\n",
    "print(actions_0)\n",
    "print('***********************************************')\n",
    "print(actions_1)\n",
    "print('***********************************************')\n",
    "print(rewards)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['[walk] <bathroom> (1)', '[walk] <bedroom> (67)', '[walk] <dining_room> (201)', '[walk] <door> (222)', '[walk] <ceilinglamp> (223)', '[walk] <ceilinglamp> (224)', '[walk] <tvstand> (225)', '[walk] <table> (226)', '[walk] <bench> (227)', '[walk] <bench> (228)', '[walk] <cupboard> (229)', '[walk] <kitchen_counter> (230)', '[walk] <faucet> (232)', '[walk] <bookshelf> (233)', '[walk] <wallshelf> (234)', '[walk] <wallshelf> (235)', '[walk] <mat> (236)', '[walk] <mat> (237)', '[walk] <drawing> (238)', '[walk] <drawing> (239)', '[walk] <drawing> (240)', '[walk] <drawing> (241)', '[walk] <drawing> (242)', '[walk] <drawing> (243)', '[walk] <orchid> (244)', '[walk] <light> (245)', '[walk] <powersocket> (246)', '[walk] <phone> (247)', '[walk] <television> (248)', '[walk] <wall_clock> (249)', '[walk] <photoframe> (285)', '[walk] <stovefan> (288)', '[walk] <freezer> (289)', '[walk] <coffe_maker> (290)', '[walk] <toaster> (292)', '[walk] <oven> (295)', '[walk] <microwave> (297)', '[walk] <home_office> (319)', '[walk] <knife> (2003)', '[walk] <cup> (2009)', '[turnto] <dining_room> (201)', '[turnto] <kitchen_counter> (230)', '[turnto] <home_office> (319)', '[touch] <kitchen_counter> (230)']\n",
      "***********************************************\n",
      "['[walk] <bathroom> (1)', '[walk] <bedroom> (67)', '[walk] <dining_room> (201)', '[walk] <home_office> (319)', '[walk] <doorjamb> (346)', '[walk] <doorjamb> (347)', '[walk] <window> (348)', '[walk] <ceilinglamp> (349)', '[walk] <walllamp> (350)', '[walk] <walllamp> (351)', '[walk] <couch> (352)', '[walk] <tvstand> (353)', '[walk] <bookshelf> (354)', '[walk] <chair> (356)', '[walk] <desk> (357)', '[walk] <dresser> (358)', '[walk] <filing_cabinet> (399)', '[walk] <drawing> (400)', '[walk] <mat> (401)', '[walk] <drawing> (402)', '[walk] <drawing> (403)', '[walk] <drawing> (404)', '[walk] <pillow> (405)', '[walk] <curtain> (409)', '[walk] <television> (410)', '[walk] <light> (411)', '[walk] <powersocket> (412)', '[walk] <mouse> (413)', '[walk] <mousepad> (414)', '[walk] <keyboard> (415)', '[walk] <cpuscreen> (416)', '[walk] <computer> (417)', '[walk] <photoframe> (430)', '[walk] <form> (2002)', '[walk] <check> (2005)', '[walk] <video_game_controller> (2006)', '[walk] <dvd_player> (2012)', '[grab] <video_game_controller> (2006)', '[switchoff] <video_game_controller> (2006)', '[turnto] <dining_room> (201)', '[turnto] <home_office> (319)', '[turnto] <video_game_controller> (2006)', '[touch] <video_game_controller> (2006)', '[push] <video_game_controller> (2006)', '[pull] <video_game_controller> (2006)', '[move] <video_game_controller> (2006)', '[plugout] <video_game_controller> (2006)']\n",
      "***********************************************\n",
      "[0.0, 0.0]\n"
     ]
    }
   ],
   "source": [
    "rewards, states, infos = env.step({0: '[walk] <kitchen_counter> (230)', 1: '[walk] <video_game_controller> (2006)'})\n",
    "actions_0 = env.get_action_space(0)\n",
    "actions_1 = env.get_action_space(1)\n",
    "print(actions_0)\n",
    "print('***********************************************')\n",
    "print(actions_1)\n",
    "print('***********************************************')\n",
    "print(rewards)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['[walk] <bathroom> (1)', '[walk] <bedroom> (67)', '[walk] <dining_room> (201)', '[walk] <door> (222)', '[walk] <ceilinglamp> (223)', '[walk] <ceilinglamp> (224)', '[walk] <tvstand> (225)', '[walk] <table> (226)', '[walk] <bench> (227)', '[walk] <bench> (228)', '[walk] <cupboard> (229)', '[walk] <kitchen_counter> (230)', '[walk] <faucet> (232)', '[walk] <bookshelf> (233)', '[walk] <wallshelf> (234)', '[walk] <wallshelf> (235)', '[walk] <mat> (236)', '[walk] <mat> (237)', '[walk] <drawing> (238)', '[walk] <drawing> (239)', '[walk] <drawing> (240)', '[walk] <drawing> (241)', '[walk] <drawing> (242)', '[walk] <drawing> (243)', '[walk] <orchid> (244)', '[walk] <light> (245)', '[walk] <powersocket> (246)', '[walk] <phone> (247)', '[walk] <television> (248)', '[walk] <wall_clock> (249)', '[walk] <photoframe> (285)', '[walk] <stovefan> (288)', '[walk] <freezer> (289)', '[walk] <coffe_maker> (290)', '[walk] <toaster> (292)', '[walk] <oven> (295)', '[walk] <microwave> (297)', '[walk] <home_office> (319)', '[walk] <knife> (2003)', '[walk] <cup> (2009)', '[grab] <cup> (2009)', '[turnto] <dining_room> (201)', '[turnto] <kitchen_counter> (230)', '[turnto] <home_office> (319)', '[turnto] <cup> (2009)', '[touch] <kitchen_counter> (230)', '[touch] <cup> (2009)', '[push] <cup> (2009)', '[pull] <cup> (2009)', '[move] <cup> (2009)']\n",
      "***********************************************\n",
      "['[walk] <bathroom> (1)', '[walk] <bedroom> (67)', '[walk] <dining_room> (201)', '[walk] <home_office> (319)', '[walk] <doorjamb> (346)', '[walk] <doorjamb> (347)', '[walk] <window> (348)', '[walk] <ceilinglamp> (349)', '[walk] <walllamp> (350)', '[walk] <walllamp> (351)', '[walk] <couch> (352)', '[walk] <tvstand> (353)', '[walk] <bookshelf> (354)', '[walk] <chair> (356)', '[walk] <desk> (357)', '[walk] <dresser> (358)', '[walk] <filing_cabinet> (399)', '[walk] <drawing> (400)', '[walk] <mat> (401)', '[walk] <drawing> (402)', '[walk] <drawing> (403)', '[walk] <drawing> (404)', '[walk] <pillow> (405)', '[walk] <curtain> (409)', '[walk] <television> (410)', '[walk] <light> (411)', '[walk] <powersocket> (412)', '[walk] <mouse> (413)', '[walk] <mousepad> (414)', '[walk] <keyboard> (415)', '[walk] <cpuscreen> (416)', '[walk] <computer> (417)', '[walk] <photoframe> (430)', '[walk] <form> (2002)', '[walk] <check> (2005)', '[walk] <video_game_controller> (2006)', '[walk] <dvd_player> (2012)', '[putback] <video_game_controller> (2006) <video_game_controller> (2006)', '[switchoff] <video_game_controller> (2006)', '[turnto] <dining_room> (201)', '[turnto] <home_office> (319)', '[turnto] <video_game_controller> (2006)', '[drop] <video_game_controller> (2006)', '[touch] <video_game_controller> (2006)', '[push] <video_game_controller> (2006)', '[pull] <video_game_controller> (2006)', '[move] <video_game_controller> (2006)', '[plugout] <video_game_controller> (2006)']\n",
      "***********************************************\n",
      "[0.0, 0.0]\n"
     ]
    }
   ],
   "source": [
    "rewards, states, infos = env.step({0: '[walk] <cup> (2009)', 1: '[grab] <video_game_controller> (2006)'})\n",
    "actions_0 = env.get_action_space(0)\n",
    "actions_1 = env.get_action_space(1)\n",
    "print(actions_0)\n",
    "print('***********************************************')\n",
    "print(actions_1)\n",
    "print('***********************************************')\n",
    "print(rewards)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['[walk] <bathroom> (1)', '[walk] <mat> (22)', '[walk] <curtain> (25)', '[walk] <ceilinglamp> (26)', '[walk] <walllamp> (27)', '[walk] <walllamp> (28)', '[walk] <walllamp> (29)', '[walk] <bathtub> (30)', '[walk] <towel_rack> (31)', '[walk] <towel_rack> (32)', '[walk] <towel_rack> (33)', '[walk] <towel_rack> (34)', '[walk] <wallshelf> (35)', '[walk] <shower> (36)', '[walk] <toilet> (37)', '[walk] <shower> (38)', '[walk] <bathroom_cabinet> (40)', '[walk] <bathroom_counter> (41)', '[walk] <faucet> (43)', '[walk] <door> (44)', '[walk] <doorjamb> (45)', '[walk] <window> (63)', '[walk] <light> (64)', '[walk] <bedroom> (67)', '[walk] <dining_room> (201)', '[walk] <home_office> (319)', '[walk] <band-aids> (2001)', '[turnto] <bathroom> (1)', '[turnto] <dining_room> (201)', '[turnto] <home_office> (319)']\n",
      "***********************************************\n",
      "['[walk] <bathroom> (1)', '[walk] <bedroom> (67)', '[walk] <dining_room> (201)', '[walk] <door> (222)', '[walk] <ceilinglamp> (223)', '[walk] <ceilinglamp> (224)', '[walk] <tvstand> (225)', '[walk] <table> (226)', '[walk] <bench> (227)', '[walk] <bench> (228)', '[walk] <cupboard> (229)', '[walk] <kitchen_counter> (230)', '[walk] <faucet> (232)', '[walk] <bookshelf> (233)', '[walk] <wallshelf> (234)', '[walk] <wallshelf> (235)', '[walk] <mat> (236)', '[walk] <mat> (237)', '[walk] <drawing> (238)', '[walk] <drawing> (239)', '[walk] <drawing> (240)', '[walk] <drawing> (241)', '[walk] <drawing> (242)', '[walk] <drawing> (243)', '[walk] <orchid> (244)', '[walk] <light> (245)', '[walk] <powersocket> (246)', '[walk] <phone> (247)', '[walk] <television> (248)', '[walk] <wall_clock> (249)', '[walk] <photoframe> (285)', '[walk] <stovefan> (288)', '[walk] <freezer> (289)', '[walk] <coffe_maker> (290)', '[walk] <toaster> (292)', '[walk] <oven> (295)', '[walk] <microwave> (297)', '[walk] <home_office> (319)', '[walk] <knife> (2003)', '[walk] <cup> (2009)', '[turnto] <bathroom> (1)', '[turnto] <dining_room> (201)', '[turnto] <kitchen_counter> (230)', '[turnto] <home_office> (319)', '[turnto] <cup> (2009)']\n",
      "***********************************************\n",
      "[0.0, 0.0]\n"
     ]
    }
   ],
   "source": [
    "rewards, states, infos = env.step({0: '[walk] <bathroom> (1)', 1: '[walk] <dining_room> (201)'})\n",
    "actions_0 = env.get_action_space(0)\n",
    "actions_1 = env.get_action_space(1)\n",
    "print(actions_0)\n",
    "print('***********************************************')\n",
    "print(actions_1)\n",
    "print('***********************************************')\n",
    "print(rewards)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "rewards, states, infos = env.step('[walk] <door> (44)')\n",
    "actions = env.get_action_space()\n",
    "print(actions)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
